package com.ruoyi.project.jiaqin.commentreply.service.impl;

import java.util.List;
import java.util.UUID;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.project.jiaqin.commentreply.mapper.NewsCommentReplyMapper;
import com.ruoyi.project.jiaqin.commentreply.domain.NewsCommentReply;
import com.ruoyi.project.jiaqin.commentreply.service.INewsCommentReplyService;
import com.ruoyi.common.utils.text.Convert;

/**
 * 评论回复Service业务层处理
 *
 * @author admin
 * @date 2020-12-15
 */
@Service
public class NewsCommentReplyServiceImpl implements INewsCommentReplyService
{
    @Autowired
    private NewsCommentReplyMapper newsCommentReplyMapper;

    /**
     * 查询评论回复
     *
     * @param id 评论回复ID
     * @return 评论回复
     */
    @Override
    public NewsCommentReply selectNewsCommentReplyById(String id)
    {
        return newsCommentReplyMapper.selectNewsCommentReplyById(id);
    }

    /**
     * 查询评论回复列表
     *
     * @param newsCommentReply 评论回复
     * @return 评论回复
     */
    @Override
    public List<NewsCommentReply> selectNewsCommentReplyList(NewsCommentReply newsCommentReply)
    {
        return newsCommentReplyMapper.selectNewsCommentReplyList(newsCommentReply);
    }

    @Override
    public PageInfo<NewsCommentReply> selectNewsCommentReplyListByCommentId(Integer pageNum, Integer pageSize, String commentId) {
        NewsCommentReply newsCommentReply = new NewsCommentReply();
        newsCommentReply.setNewsCommentId(commentId);
        PageHelper.startPage(pageNum,pageSize);
        List<NewsCommentReply> list = newsCommentReplyMapper.selectNewsCommentReplyList(newsCommentReply);
        PageInfo<NewsCommentReply> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    /**
     * 新增评论回复
     *
     * @param newsCommentReply 评论回复
     * @return 结果
     */
    @Override
    public int insertNewsCommentReply(NewsCommentReply newsCommentReply)
    {
        newsCommentReply.setId(UUID.randomUUID().toString().replace("-",""));
        return newsCommentReplyMapper.insertNewsCommentReply(newsCommentReply);
    }

    /**
     * 修改评论回复
     *
     * @param newsCommentReply 评论回复
     * @return 结果
     */
    @Override
    public int updateNewsCommentReply(NewsCommentReply newsCommentReply)
    {
        return newsCommentReplyMapper.updateNewsCommentReply(newsCommentReply);
    }

    /**
     * 删除评论回复对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteNewsCommentReplyByIds(String ids)
    {
        return newsCommentReplyMapper.deleteNewsCommentReplyByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除评论回复信息
     *
     * @param id 评论回复ID
     * @return 结果
     */
    @Override
    public int deleteNewsCommentReplyById(String id)
    {
        return newsCommentReplyMapper.deleteNewsCommentReplyById(id);
    }
}
